package com.allwees.bs.c.module.payment.req;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import javax.xml.bind.annotation.XmlRootElement;

/**
 * @author Daniel
 * @version 1.0.0
 * @since 2020/12/5 19:58
 */
@Getter
@Setter
@ToString
@XmlRootElement(name = "response")
public class OceanpayCallback {
    //****公用部分****//
    private String account;
    private String terminal;
    private String signValue;
    private String order_number;
    private String order_currency;
    private String order_amount;
    private String payment_id;
    //****支付回调专有部分****//
    /**
     * 0: 浏览器回调
     * 1: 服务器回调
     */
    private String response_type;
    private String methods;
    private String order_notes;
    private String card_number;
    private String payment_country;
    private String payment_authType;
    /**
     * -1: 待处理(预授权才会有)
     * 0: 失败
     * 1: 成功
     */
    private String payment_status;
    private String payment_details;
    private String payment_risk;
    private String payment_solutions;
    private String auth_reason;
    private String order_operator;

    //****退款回调/其他推送专有部分****//
    private String payment_dateTime;
    private String push_dateTime;
    private String card_type;
    /**
     *退款
     * refund (全额退款)
     * partialRefund (部分退款)
     *
     *其他
     *  chargeBack：拒付推送
     *  re-presentment：申诉推送
     *  retrieval：调单推送
     *  reversal-retrieval：撤销调单推送
     */
    private String notice_type;
    private String push_id;
    /**
     * 退款状态
     *  0：退款失败
     *  1：退款成功
     *
     * 其他
     *  0：失败
     *  1：成功
     *  2：申诉中 (仅 notice_type 为 re-presentment 才有)
     */
    private String push_status;
    private String push_details;


    public boolean isPaymentSuccess(){
        return "1".equals(response_type) && "1".equals(payment_status);
    }

    public boolean isRefundSuccess(){
        return ("refund".equals(notice_type) || "partialRefund".equals(notice_type)) && "1".equals(push_status);
    }
}